﻿var adWim = function(obj){
    var el = $(obj);
    var size = el.getSize();
    var top = $(document.body).getSize().y + $(document.body).scrollTop;
    var left = "0px";
    window.addEvent('resize', function(){
        top = $(document.body).getSize().y;
        el.setStyles({ 'top': top - size.y, 'left': left });
        //el.innerHTML = top;
    });
    window.addEvent('scroll', function(){
        var win = $(document.body)
        top = win.getSize().y + win.scrollTop;
        el.setStyles({ 'top': top - size.y, 'left': left });
        //el.innerHTML = top;
    });
    this.show = function(){
    if (el.getStyle('visibility')=='visible') return false;
    new Fx.Morph(el, {
        duration: 1000,
        transition: Fx.Transitions.Sine.easeInOut
        /*onComplete: function(){ alert('Complete'); }*/
    }).start({
        'visibility': 'visible',
        'top': [top, top - size.y],
        'left': left,
        'opacity':[0, 1]
    });
    //el.innerHTML = top;
    };
    this.hide = function(){
        if (el.getStyle('visibility')=='hidden') return false;
        new Fx.Morph(el, {
            duration: 1000,
            transition: Fx.Transitions.Sine.easeInOut,
            onComplete: function(){ el.setStyle('visibility', 'hidden'); }
        }).start({
            'top': [top - size.y, top],
            'left': left,
            'opacity':[1, 0]
        });
    };
}